#!/bin/bash

if [ "$1" = "rm" ]; then
   shift
   rmsbdir "$@"
   exit $?
fi 

if [ "$1" = "rmdir" ]; then
   shift
   rmsbdir "$@"
   exit $?
fi 

if [ "$1" = "conv" ]; then
   shift
fi

if [ ! -r "$1" ]; then
   echo File not found "$1"
   exit 1
fi

if [ -d "$1" -a "$(basename "$1")" = "initrfs.img" ]; then
   initramfs_pack "$1"
   exit $?
fi

if [ -f "$1" -a "$(basename "$1")" = "initrfs.img" ]; then
   initramfs_unpack "$1"
   exit $?
fi

if [ -d "$1" ]; then
   dir2sb "$@"
   exit $?
fi

sb2dir "$@"
